#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main() {
    int n, a, b, c;
    cin >> n;
    while (n--)
    {
        int ret = 0;
        cin >> a >> b >> c;
        ret += min(a, min(b, c)) * 2;
        b -= ret / 2;
        if (b >= 2)
            ret += b - 1;
        cout << ret << endl;
    }
    return 0;
}